<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <h:form id="relatorioCadastroIndividualForm" enctype="multipart/form-data">
                <br/>
                <h3 class="title">Relatório Cadastro Individual Genérico</h3>
                <p:growl id="messages" showDetail="true" autoUpdate="true"  /> 
                <p:panel id="pacientesPanel" style="background: none; border: none;" 
                         styleClass="container_24 clearfix both ">
                    <h4 class="title">Pacientes com :</h4>
                    <p:outputLabel value="Tuberculose:" styleClass="grid_3"/>
                    <p:selectBooleanCheckbox value="#{managerRelarioCadastroIndividual.questionarioAutoReferido.tuberculose}" styleClass="grid_5"/> 
                    <p:outputLabel value="Diabetes:" styleClass="grid_3"/>
                    <p:selectBooleanCheckbox value="#{managerRelarioCadastroIndividual.questionarioAutoReferido.diabetes}" styleClass="grid_5"/> 
                    <p:outputLabel value="Gestante:" styleClass="grid_3"/>
                    <p:selectBooleanCheckbox value="#{managerRelarioCadastroIndividual.questionarioAutoReferido.gestante}" styleClass="grid_5"/> 
                    <p:outputLabel value="Cancer:" styleClass="grid_3"/>
                    <p:selectBooleanCheckbox value="#{managerRelarioCadastroIndividual.questionarioAutoReferido.cancer}" styleClass="grid_5"/> 
                    <p:outputLabel value="Dsts Aids:" styleClass="grid_3"/>
                    <p:selectBooleanCheckbox value="#{managerRelarioCadastroIndividual.questionarioAutoReferido.dstsAids}" styleClass="grid_5"/> 
                    <p:outputLabel value="Hipertensão:" styleClass="grid_3"/>
                    <p:selectBooleanCheckbox value="#{managerRelarioCadastroIndividual.questionarioAutoReferido.hipertensao}" styleClass="grid_5"/> 
                    <p:outputLabel value="AVC:" styleClass="grid_3"/>
                    <p:selectBooleanCheckbox value="#{managerRelarioCadastroIndividual.questionarioAutoReferido.avc}" styleClass="grid_5"/> 

                </p:panel> 
                <p:panel id="pacientePossuePanel" style="background: none; border: none;" 
                         styleClass="container_24 clearfix both ">
                    <h4 class="title">Pacientes que Posssuem :</h4> 
                    <p:outputLabel value="Doença Cardíaca:" styleClass="grid_3"/> 
                    <p:selectBooleanCheckbox value="#{managerRelarioCadastroIndividual.questionarioAutoReferido.possuiDoencaCardiaca}" styleClass="grid_5"/> 
                    <p:outputLabel value="Doença Pulmonar:" styleClass="grid_3"/>
                    <p:selectBooleanCheckbox value="#{managerRelarioCadastroIndividual.questionarioAutoReferido.possuiDoencaPulmonar}" styleClass="grid_5"/> 
                    <p:outputLabel value="Doença Renal:" styleClass="grid_3"/>
                    <p:selectBooleanCheckbox value="#{managerRelarioCadastroIndividual.questionarioAutoReferido.possuiProblemaRenal}" styleClass="grid_5"/> 


                </p:panel>
                <p:panel id="microPanel" style="background: none; border: none;" 
                         styleClass="container_24 clearfix both ">
                    <h4 class="title">Micro Área :</h4>


                    <p:outputLabel value="Micro Área:" styleClass="grid_3"/>
                    <p:autoComplete styleClass="grid_16" dropdown="true" converter="microareaconverter"
                                    var="cityValue" itemLabel="#{cityValue.nome.toString().concat(' - ').concat(cityValue.unidade.nome)}"
                                    itemValue="#{cityValue}" value="#{managerRelarioCadastroIndividual.microArea}"
                                    scrollHeight="200" forceSelection="true"
                                    completeMethod="#{managerRelarioCadastroIndividual.autocomplete}"/>


                </p:panel>

                <div class="buttonAction">
                    <p:commandButton id="pesquisarCommandButton" value="Pesquisar" icon="ui-icon-search"
                                     update="cadastroIndividualTable" 
                                     actionListener="#{managerRelarioCadastroIndividual.pesquisar()}"
                                     />

                    <p:commandButton  
                        title="Imprimir"
                        update="@form" ajax="false"
                        process="@this" icon="ui-icon-print"
                        onclick="this.form.target='_blank'"
                        actionListener="#{managerRelarioCadastroIndividual.relatorioCadastroIndividualCidadaoDoenca()}"
                        value="Imprimir"/>

                    <p:button href="index.xhtml" value="Cancelar"  icon="ui-icon-trash" />
                </div >

                <p:blockUI id="BLOCK" block="resultPanel" trigger="pesquisarCommandButton, cadastroIndividualTable" > 
                    <p:graphicImage value="media/images/ajax-loader.gif"/>
                </p:blockUI> 


                <p:panel id="resultPanel" style="background: none; border: none;" 
                         styleClass="container_24 clearfix ">
                    <h4 class="title">Resultado</h4>

                    <p:dataTable id="cadastroIndividualTable" var="item" value="#{managerRelarioCadastroIndividual.cadastroIndividuais}" 
                                 styleClass="grid_24" rowIndexVar="rowid"                 
                                 rows="5" paginator="true" lazy="true"   
                                 paginatorTemplate="{FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
                                 currentPageReportTemplate="{currentPage} de {totalPages}"
                                 paginatorPosition="bottom" emptyMessage="Nenhum registro encontrado"
                                 style="white-space: pre-wrap;">

                        <f:facet name="header">
                            <p:outputLabel value="Cadastro Individual" />
                        </f:facet> 
                        <p:column headerText="Ação" width="50">

                            <p:button title="Visualizar"
                                      href="visualizarprofissional.xhtml?visualizarProfissional=#{item.id}"
                                      icon="ui-icon-zoomin"/> 

                        </p:column>

                        <p:column headerText="Nome">  
                            <h:outputText value="#{item.cidadao.nome}" />                          
                        </p:column>
                        <p:column headerText="Numero SUS">  
                            <h:outputText value="#{item.cidadao.numeroCartaoSus}"/>
                        </p:column> 
                        <p:column headerText="Micro Área ">  
                            <h:outputText value="#{item.profissional.microArea.nome}"/>
                        </p:column> 

                    </p:dataTable> 

                </p:panel>


            </h:form>
        </ui:define>
    </ui:composition>

</html>
